package com.daiyang.lotterysystem.dao.mapper;

import com.daiyang.lotterysystem.dao.dataobject.Encrypt;
import com.daiyang.lotterysystem.dao.dataobject.UserDO;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {
    /**
     * 查询邮箱绑定的人数
     * @param email
     * @return
     */
    @Select("SELECT COUNT(*) FROM user WHERE email = #{email}")
    int countEmail(@Param("email") String email);
    @Select("SELECT COUNT(*) FROM user WHERE phone_number = #{phoneNumber}")
    int countPhoneNumber(@Param("phoneNumber") Encrypt phoneNumber);
    @Insert("INSERT INTO user(user_name, email, identity, password, phone_number)"+
            " VALUES(#{userName}, #{email}, #{identity}, #{password}, #{phoneNumber})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void insert(UserDO userDO);
}